Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE-6941 add description and keywords #25

Merged
merged 10 commits into from
Oct 22, 2024

Conversation

vilenarios
Copy link
Contributor

No description provided.

README.md Outdated
| Tag Name | Type | Pattern | Required | Description |
| ----------- | ------ | ----------------- | -------- | --------------------------------- |
| Action | string | "Set-Description" | true | Action tag for triggering handler |
| Description | string | N/A | true | New description for ANT. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pattern is 512 characters. Could specify utf-8 only but the limit is probably fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added 512 character pattern.

README.md Outdated
| Tag Name | Type | Pattern | Required | Description |
| -------- | ------ | -------------- | -------- | --------------------------------- |
| Action | string | "Set-Keywords" | true | Action tag for triggering handler |
| Keywords | table | "^[%w-_]+$" | true | New keywords for ANT. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| Keywords | table | "^[%w-_]+$" | true | New keywords for ANT. |
| Keywords | table | "^[%w-_]{1,32}$" | true | New keywords for ANT. |

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider allowing special characters - could allow integrations with apps that use # and @ for pointing to specific topics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added # and @.


#### `Set-Keywords`

Sets the keywords for the ANT.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth mentioned max table size of 16 and min of 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this to include that detail.


function balances.setKeywords(keywords)
assert(type(keywords) == "table", "Keywords must be an array")
assert(#keywords <= 16, "There must not be more than 16 keywords")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recommend add a check for the table containing atleast 1 keyword

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if they want to empty their keywords?

Comment on lines 33 to 45
assert(type(keywords) == "table", "Keywords must be an array")
assert(#keywords <= 16, "There must not be more than 16 keywords")

local seenKeywords = {}
for _, keyword in ipairs(keywords) do
assert(type(keyword) == "string", "Each keyword must be a string")
assert(#keyword <= 32, "Each keyword must not be longer than 32 characters")
assert(not keyword:find("%s"), "Keywords must not contain spaces")
assert(keyword:match("^[%w-_]+$"), "Keywords must only contain alphanumeric characters, dashes, or underscores")
assert(not seenKeywords[keyword], "Duplicate keyword detected: " .. keyword)
seenKeywords[keyword] = true
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is all duplicate code, recommend pulling this out into a validation util and using here as well as in the setKeyword util

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point. Added utility function to validate keywords.

@atticusofsparta atticusofsparta changed the title Pe 6941 add description and keywords PE-6941 add description and keywords Oct 16, 2024
@atticusofsparta atticusofsparta force-pushed the PE-6941-add-description-and-keywords branch from 1585978 to be0b48f Compare October 21, 2024 16:58
@vilenarios vilenarios merged commit d6d597e into develop Oct 22, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants